<template>
  <div>
    <Header @logout="handleLogout" />
    <router-view />
  </div>
</template>
<script>
import Header from '@/components/Header.vue'
export default {
  components: { Header },
  methods: {
    async handleLogout() {
      try {
        await this.$confirm('确定要退出登录吗？', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        })
        localStorage.removeItem('token')
        this.$store.commit('CLEAR_PROFILE')
        this.$router.replace('/login')
        this.$message.success('退出登录成功')
      } catch (_) {
        this.$message.info('已取消退出登录')
      }
    }
  }
}
</script>